<script type="text/javascript">
    $(document).ready(function () {
        // Clears Cart
        $('.clear-cart').click(function () {
            $.ajax({
                url: "<%= empty_cart_url %>",
                type: "POST",
                dataType : "script"
            });
        });

        // Updates subtotal and total when an item's quantity changes
        $('#cart-items').on('change', '.prod-qty input', function () {
            parsedQuantity = parseFloat($(this).val());
            itemId = $(this).parent().siblings('input[type="hidden"]').first().val();

            if (!isNaN(parsedQuantity) && itemId != undefined) {
                $.ajax({
                    url: "<%= change_item_quantity_cart_url %>",
                    data: {
                        item_id: itemId,
                        quantity: parsedQuantity
                    },
                    type: "POST",
                    dataType : "script"
                });
            }
        });

        $('#cart-items').on('click', '.prod-qty input', function () {
            this.select();
        });

        <% if @show_alert %>
            $('#pending-order-alert').modal({
                overlayClose: true,
                closeClass: 'modal-close'
            });
        <% end %>
    });
</script>

<div class="content container">
                <div class="bread-crumbs products checkout-page">
                    <div class="container">
                        <div class="row">
                            <ul>
                                <li class="crumb"><a href="<%= root_url %>">Home</a></li>
                                <li><i class="fa fa-angle-double-right"></i></li>
                                <li class="current-crumb">Productos seleccionados</li>
                            </ul>
                        </div>
                    </div>
                </div>
			<div class="row">
				<div class="row">
					<div class="content-shopping-cart">
                        <div id="cart-items"><%= render :partial => 'cart_items', :locals => { :items => @cart.items } %></div>
					</div>
				</div>
			</div>
				<div class="box-section info-section single-post checkout-page">
				</div>
				<!-- section div.info-section -->
		</div>

<div id="pending-order-alert" class="warning-modal" style="display: none;">
    <h1>ORDEN NO FINALIZADA</h1>

    <p>Ten&eacute;s una orden de compra sin finalizar. Si quer&eacute;s cancelarla, hac&eacute; click en el bot&oacute;n "VACIAR CARRITO".</p>

    <p class="ok-link modal-close">Entendido</p>
</div>